home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / GMSMTH01.ZIP / INCLUDE / TILEMAP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-15  |  5.8 KB  |  182 lines

  1. /*
  2.  
  3.    FILE : tilemap.h
  4.  
  5.  
  6.    HISTORY:
  7. */
  8.  
  9. #ifndef DEF_TILEMAP
  10. #define DEF_TILEMAP 1
  11.  
  12. #include <sprite.h>
  13.  
  14.  
  15. // tile attribute bits
  16.  
  17. #define  TILE_IMPASSABLE 0x1
  18. #define  TILE_BLASTABLE  0x2
  19. #define  TILE_OPAQUE     0x3
  20. #define  TILE_DOOR       0x4
  21.  
  22. #define  TILE_MOVE_UP    0x5
  23. #define  TILE_MOVE_DOWN  0x6
  24. #define  TILE_MOVE_LEFT  0x7
  25. #define  TILE_MOVE_RIGHT 0x8
  26.  
  27.  
  28. // Miscellaneous
  29. #define PBM_HEADER_SIZE 2
  30. #define NUM_TILE_GROUPS 256
  31. #define FNAMES_SIZE 15
  32.  
  33. // NOTE !! these must be big enough to hold total of all types that can be placed
  34. //         only max for each sub-type is check, not overall max on map
  35. #define MAX_LODRESS  256  // max number of over dresses on map
  36. #define MAX_HIDRESS  256   // max number of normal/under dresses on the map
  37. #define MAX_ANIM 256
  38.  
  39. typedef struct
  40. {
  41. short start, end;    // index into bitmap array for group of tiles
  42. } tile_data_t;
  43.  
  44. typedef struct
  45. {
  46. tile_data_t groups[NUM_TILE_GROUPS];
  47. } ed_info_t;
  48.  
  49.  
  50. typedef struct
  51.    {
  52.    short x, y;   // pixel location on the map
  53.    BYTE index;   // index into appropiate lib of data
  54.    BYTE attrib;  // attributes for object (same as tiles)
  55.    }
  56. instance_t;
  57.  
  58.  
  59. typedef struct
  60.    {
  61.    // names of files associated with this map
  62.    char tile_name[FNAMES_SIZE];         // tile array file
  63.    char dress_name[FNAMES_SIZE];        // dressings library file
  64.    char anim_name[FNAMES_SIZE];         // sprite files library file
  65.    char edinfo_name[FNAMES_SIZE];       // edit information file (only loaded
  66.                                //  in edit mode)
  67.    // map movement information
  68.    short x, y;           // where the map top left corner should be
  69.    short win_tile_cols, win_tile_rows;
  70.    short actual_x[2];    // screen top left corner on map (pixels - each page)
  71.    short actual_y[2];    // screen top left corner on map (pixels - each page)
  72.    short win_left, win_right;   // min, max for left side of screen in map (pixels)
  73.    short win_top, win_bottom;   // min, max for top of screen in map (pixels)
  74.    short min_map_x, max_map_x;
  75.    short min_map_y, max_map_y;
  76.  
  77.    // tile information
  78.    BYTE tile_cols, tile_rows;  // size of map in tiles
  79.  
  80.    BYTE tile_width, tile_height;
  81.    short tile_size;
  82.  
  83.  
  84.    // tile arrays
  85.    BYTE far *tile_bitmaps;   // raw tile lib, pbm tiles in array
  86.    BYTE far *tile_inds;       // array of indexes into tile bitmaps
  87.    BYTE far *tile_attribs;    // array of tile attribute bytes
  88.                              // belongs to.
  89.    USHORT num_tile_bitmaps;
  90.    USHORT tilelib_size;
  91.  
  92.    // dressings and anims, number of each, pointers to array of locations
  93.    // (and pointers to bitmaps in libraries) on map
  94.    short num_low;
  95.    instance_t far *low_dress;  // dressing draw UNDER tanks, eg bases
  96.    short num_high;
  97.    instance_t far *high_dress; // dressing to be drawn OVER tanks etc...
  98.    short num_anims;
  99.    instance_t far *anim;       // anims (sprites)
  100.  
  101.    BYTE far *dress_lib;   // raw dresslib, has header, followed by var length pbm,s
  102.    BYTE far *anim_lib;     // raw anim lib
  103.    sprite_bank_t far *spr_bank;    // sprite bank for anims
  104.  
  105.    USHORT dresslib_size;
  106.    USHORT animlib_size;
  107.  
  108.    ed_info_t far *ed_info;   // edit information structure (only loaded/used
  109.                             //  in edit mode)
  110.    void far *user0;          // misc. pointers for specific implementations
  111.    void far *user2;
  112.    void far *user3;
  113.    void far *user4;
  114.    }
  115. map_t;
  116.  
  117. // used to update the screen
  118. enum last_moves
  119.    {
  120.    NO_MOVE,
  121.    MOVE_RIGHT,
  122.    MOVE_LEFT,
  123.    MOVE_UP,
  124.    MOVE_DOWN,
  125.    MOVE_UP_RIGHT,
  126.    MOVE_DOWN_RIGHT,
  127.    MOVE_UP_LEFT,
  128.    MOVE_DOWN_LEFT,
  129.    UPDATE_TILES,
  130.    UPDATE_DRESS,
  131.    UPDATE_BOTH
  132.    };
  133.  
  134. // init new maps
  135. map_t far *new_tile_map(
  136.               char *edInfoFileName,              // edit information file name
  137.               char *tileFileName,                // tile library file name
  138.               char *dressFileName,               // dress library file name
  139.               char *animFileName,                // anim  library file name
  140.               short winLeft, short winRight,
  141.               short winTop, short winBottom,     // screen window
  142.               short tileRows, short tileColumns, // how big is map
  143.               short dfltStartTile, short dfltEndTile );// range of default tiles
  144.                                                  // to be placed randomly
  145. void calc_map(map_t far *map);
  146.  
  147. // load, save maps
  148. map_t far *load_tile_map( char *fname, short winLeft, short winRight,
  149.                                      short winTop,  short winBottom );
  150. map_t far *load_edit_tile_map( char *fname, char *edInfoFileName, short winLeft, short winRight,
  151.                                    short winTop,  short winBottom );
  152.  
  153. short save_tile_map(map_t far *map, char *fname );
  154. short save_tile_lib( map_t far *map );
  155. void deinit_tile_map(map_t far *map);
  156.  
  157.  
  158. // drawing routines
  159. void update_map_except_high_dressings( map_t far *map );
  160. void draw_map_except_high_dressings( map_t far *map );
  161. void draw_low_dressings(map_t far *map);
  162. void draw_high_dressings(map_t far *map);
  163. void draw_all_tiles( map_t far *map );
  164. void update_tiles(map_t far *map);
  165.  
  166. // moving routines
  167. void get_mouse_movemap_state(map_t far *map, short *p_move_state);
  168. void move_map_xy( map_t far *map, short dx, short dy );
  169. void move_map_vector( map_t far *map, short scroll_pixels, short vector );
  170.  
  171. // map anims (sprites) routines
  172. BYTE far *get_lib_ptr(  BYTE far *lib, short index );
  173. void init_map_sprite_instances( map_t far *map  );
  174.  
  175. // collision with tiles, tile attributes
  176. short get_tile_attrib( map_t far *map, short x, short y );
  177. short will_collide_with_tile( map_t far *map, sprite_t far *s );
  178. void kill_sprites_at_impassable_tiles( map_t far *map, sprite_bank_t far *bank );
  179. void stop_sprites_at_impassable_tiles( map_t far *map, sprite_bank_t far *bank );
  180.  
  181. #endif
  182.